package spark.example

import org.apache.spark.{SparkConf,SparkContext}

object closueExample {
	def main(args : Array[String]) {
		val conf = new SparkConf().setAppName("spark closue example")
		val sc = new SparkContext(conf)
		// var counter = 0
		val data = Array(123,456,789)
		var rdd = sc.parallelize(data)
		//rdd.foreach(x => counter += x)
                val accum = sc.accumulator(0)
                rdd.foreach(x => accum += x)

		println("accum value: " + accum)
	}
}
